import socket
import os
import time
server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server.bind(('192.168.0.114',3838)) 
server.listen(5) 
while True:
    conn,addr = server.accept()
    print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())),end=" ")
    print(addr,end=" ")
    try:
        data = conn.recv(1024)
        word=data.decode() 
        print('说:',word)
        is_cmd=word.find('/cmd ')
        if is_cmd==0:
            os.system(word[5:])
        data=(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+str(addr)+"欢迎光临").encode("utf-8")
        conn.send(data.upper()) 
    except ConnectionResetError as e:
        print('出问题了')
        break
    conn.close()